# -*- coding: utf-8 -*-
# @Time    : 2024/11/7 下午1:56
# @Author  : xiaowanzi
# @File    : http_tools.py
import requests
import urllib3

# SSL警告
urllib3.disable_warnings()
requests.adapters.DEFAULT_RETRIES = 5  # 增加重连次数


def http_request():
    session = requests.session()
    session.keep_alive = False
    return session


session = http_request()


def http_get(url, params):
    s = requests.session()
    s.keep_alive = True
    resp = s.get(url=url, params=params, verify=False, timeout=2)
    s.close()
    return resp


def http_post(url, post_data):
    s = requests.session()
    s.keep_alive = False
    resp = s.post(url, json=post_data, verify=False, timeout=2)
    s.close()
    return resp
